Skip to content

Add macOS support for Vulkan applications#12

Open
ca1773130n wants to merge 1 commit intonvpro-samples:mainfrom
ca1773130n:main
Open

Add macOS support for Vulkan applications#12
ca1773130n wants to merge 1 commit intonvpro-samples:mainfrom
ca1773130n:main

Conversation

@ca1773130n
Copy link

Summary

This PR adds comprehensive macOS support for building and running Vulkan applications using nvpro_core2.

Changes

  • Vulkan Portability support (nvvk/context.cpp): Add VK_KHR_portability_enumeration extension and VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR flag for non-conformant Vulkan implementations on macOS
  • Metal surface extension (nvvk/context.cpp): Add VK_EXT_metal_surface support in addSurfaceExtensions()
  • volk platform defines (third_party/CMakeLists.txt): Use VK_USE_PLATFORM_METAL_EXT instead of X11 defines on macOS
  • Slang compiler (cmake/FindSlang.cmake): Add macOS detection for downloading correct binary; exclude GNU linker flags
  • GNU linker flags (cmake/Setup.cmake): Exclude --gc-sections on macOS (not supported by Apple linker)
  • POSIX includes (nvutils/logger.cpp): Add <unistd.h> for non-Windows platforms
  • Parallel execution (nvutils/parallel_work.hpp): Add fallback for Apple clang which lacks std::execution::par_unseq
  • Timer platform detection (nvutils/timers.cpp, nvutils/timers.hpp): Add __APPLE__ to Unix platform checks
  • Template deduction fix (nvimageformats/nv_dds.cpp): Explicit template parameter for std::min to fix type mismatch
  • Native file dialogs (nvgui/file_dialog_macos.mm, nvgui/CMakeLists.txt): Add macOS implementation using NSOpenPanel/NSSavePanel

Testing

Tested on:

  • macOS 15.x (Apple Silicon M-series)
  • MoltenVK 1.4.0
  • Vulkan SDK 1.4.x

Successfully built and ran vk_gaussian_splatting sample application.

Notes

  • All changes are guarded with #ifdef __APPLE__ or elseif(APPLE) to avoid affecting other platforms
  • Comments use general "Vulkan Portability" terminology rather than MoltenVK-specific wording

- Add Vulkan Portability extension support for instance creation
- Add VK_EXT_metal_surface extension for macOS surface creation
- Add volk platform defines for Metal (VK_USE_PLATFORM_METAL_EXT)
- Add macOS detection for Slang compiler download
- Exclude GNU-specific linker flags on macOS (--gc-sections, --disable-new-dtags)
- Add <unistd.h> include for non-Windows platforms
- Add Apple clang fallback for std::execution::par_unseq
- Add __APPLE__ to Unix platform checks in timers
- Fix std::min template deduction in nv_dds.cpp
- Add native macOS file dialog implementation using NSOpenPanel/NSSavePanel

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Cameleon X <ca1773130n@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant